package com.seal.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.seal.comm.utils.Page;
import com.seal.dao.ICompanyInfoDao;
import com.seal.dto.CompanyInfoDto;
import com.seal.model.CompanyInfo;
import com.seal.service.ICompanyInfoService;

@Service("companyInfoServiceImpl")
@Transactional(readOnly = true)
public class CompanyInfoServiceImpl implements ICompanyInfoService {

	@Resource(name = "companyInfoDaoImpl")
	private ICompanyInfoDao companyInfoDao;

	@Transactional(propagation = Propagation.REQUIRED,readOnly = false, rollbackForClassName = "Exception")
	public void addCompanyInfo(CompanyInfo ca) throws Exception {
		companyInfoDao.addCompanyInfo(ca);
	}

	@Transactional(propagation = Propagation.REQUIRED,readOnly = false, rollbackForClassName = "Exception")
	public void deleteCompanyInfo(CompanyInfo ca) throws Exception {
		companyInfoDao.deleteCompanyInfo(ca);
	}

	public List<CompanyInfo> getAllCompanyInfo(CompanyInfoDto companyInfoDto,
			Page page) throws Exception {
		return companyInfoDao.getAllCompanyInfo(companyInfoDto, page);
	}

	public CompanyInfo getCompanyInfoById(Long companyId)
			throws Exception {
		return companyInfoDao.getCompanyInfoById(companyId);
	}

	public CompanyInfo getUnRegistCompany() throws Exception {
		return companyInfoDao.getUnRegistCompany();
	}

	@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackForClassName = "Exception")
	public void updateCompanyInfo(CompanyInfo ca) throws Exception {
		companyInfoDao.updateCompanyInfo(ca);
	}

	public String getSealDistributeType(Long companyId) throws Exception {
		return companyInfoDao.getCompanyInfoById(companyId).getDistributeType();
	}

}
